package com.xunua.networkproject;

import androidx.appcompat.app.AppCompatActivity;

import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import com.xunua.networkproject.Okhttp.OkHttpActivity;
import com.xunua.networkproject.Retrofit.RetrofitActivity;
import com.xunua.networkproject.RxJavaAndButterKnife.RxJava_ButterActivity;

import butterknife.ButterKnife;
import butterknife.OnClick;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ButterKnife.bind(this);
        if (checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE)!= PackageManager.PERMISSION_GRANTED
                ||
                checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)!= PackageManager.PERMISSION_GRANTED
        ) {
            requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},0);
            requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},1);
        }
    }

    public void okhttp(View view) {
        Intent intent = new Intent(this, OkHttpActivity.class);
        startActivity(intent);
    }

    public void retrofit(View view) {
        Intent intent = new Intent(this, RetrofitActivity.class);
        startActivity(intent);
    }
    @OnClick(R.id.btn_RxjavaIntent)
    public void toRxJava(){
        Intent intent = new Intent(this, RxJava_ButterActivity.class);
        startActivity(intent);
    }
}
